<ui:composition xmlns="http://www.w3.org/1999/xhtml"
                xmlns:ui="http://java.sun.com/jsf/facelets"
                xmlns:h="http://java.sun.com/jsf/html"
                xmlns:f="http://java.sun.com/jsf/core"
                xmlns:p="http://primefaces.org/ui"
                template="../templates/principal.xhtml">
    <ui:define name="head">
        <style type="text/css">
            .ui-datatable .ui-datatable-data .loc-row td{  
                background-color:lightblue !important;
                background-image: none !important;
                color: #{processoBean.corletraloc} !important;  
            }

            .ui-datatable .ui-datatable-data .proc-row td{  
                background-color:#{processoBean.colorproc} !important;
                background-image: none !important;
                color: #{processoBean.corletraproc} !important;  
            }

            .ui-datatable .ui-datatable-data .sit-row td{  
                background-color:#{processoBean.colorsit} !important;
                background-image: none !important;
                color: #{processoBean.corletrasit} !important; 
            }

            .ui-datatable .ui-datatable-data .com-row td{  
                background-color:#{processoBean.colorcom} !important;
                background-image: none !important;
                color: #{processoBean.corletracom} !important; 
            }

            .ui-datatable .ui-datatable-data .ass-row td{  
                background-color:yellow !important;
                background-image: none !important;
                color: #{processoBean.corletraass} !important; 
            }

            .ui-datatable .ui-datatable-data .des-row td{  
                background-color:#DC8700 !important;
                background-image: none !important;
                color: #{processoBean.corletrades} !important; 
            }
            
            .ui-datatable .ui-datatable-data .err-row td{  
                background-color:#{processoBean.colorerr} !important;
                background-image: none !important;
                color: #{processoBean.corletraerr} !important;
            }

            .ui-datatable .ui-datatable-data .normal-row td{  
                background-color:#{processoBean.colornormal} !important;
                background-image: none !important;
                color: #{processoBean.corletraass} !important; 
            }

            .ui-datatable .ui-datatable-header {
                text-align:center;
            }

            .actions td {
                border: 0px none !important;
                padding: 0px !important;
                width: 50px;
            }

            .grid td {
                border: 0px none !important;
            }

            .animated .ui-progressbar-value { 
                background-image: url(../images/pbar-ani.gif); 
            }
        </style>

        <script type="text/javascript">
            jQuery(function($) {
                $("input.data:text").mask("99/99/9999");
                $("input.processo:text").mask("9999-9.999.999-9");
            });

            
        </script>
    </ui:define>

    <ui:define name="content" id="content">
        <!--
        <p:ajaxStatus onstart="statusDialog.show();" onsuccess="PF('statusDialog').hide();"/>

        <p:dialog modal="true" widgetVar="statusDialog" header="Aguarde ... Carregadando os Processos ..." draggable="false" closable="false">
            <p:graphicImage value="/design/ajaxloadingbar.gif" />
        </p:dialog>
        -->
        <h:form id="frmProcesso">
            <p:panel id="panel" header="Bem Vindo ao Modulo dos Processos">
                <p:growl id="messages" life="5000" />


                <p:panelGrid>
                    <p:row>
                        <p:column style="background-color: #ffffff;  color:#000000; font-weight: bold;">Cores das Alterações:</p:column>
                        <p:column style="background-color: lightblue; color: #{processoBean.corletraloc};">
                            LOCALIZAÇÃO
                        </p:column>
                        <p:column style="background-color: #{processoBean.colorsit}; color: #{processoBean.corletrasit};">
                            SITUAÇÃO
                        </p:column>
                        <p:column style="background-color: #{processoBean.colorproc}; color: #{processoBean.corletraproc};">
                            DADOS DO PROCESSO
                        </p:column>
                        <p:column style="background-color: yellow; color: #{processoBean.corletraass};">
                            ASSUNTOS SOLICITADOS
                        </p:column>
                        <p:column style="background-color: #{processoBean.colorcom}; color: #{processoBean.corletracom};">
                            COMUNIQUE-SE
                        </p:column>
                        <p:column style="background-color: #{processoBean.colordes}; color: #{processoBean.corletrades};">
                            DESPACHO
                        </p:column>
                        <p:column style="background-color: #{processoBean.colorerr}; color: #{processoBean.corletraerr};">
                            ERRO DE ACESSO
                        </p:column>

                    </p:row>
                </p:panelGrid>
                <p:dataTable id="empreendimentoTable" var="empreendimento" value="#{processoBean.empreendimentoLazyModel}" 
                             paginator="true" rows="12" paginatorPosition="top" lazy="true" rowIndexVar="rowIdEmpreendimento" filterEvent="enter"
                             emptyMessage="Nenhum Registro Retornado ..." resizableColumns="true">

                    <p:ajax event="rowToggle" listener="#{processoBean.onRowToggle}" update=":frmProcesso:panelProcesso" />

                    <f:facet name="header">
                        <div style="text-align: center">Processos Cadastrados</div>
                    </f:facet> 

                    <p:column style="width:150px;" headerText="No.Processo" filterBy="#{empreendimento.numProcesso}" filterStyleClass="processo">
                        <p:rowToggler />
                    </p:column>

                    <p:column style="text-align: left; " filterBy="#{empreendimento.idCliente.nomCliente}" sortBy="#{empreendimento.idCliente.nomCliente}">
                        <f:facet name="header">
                            <div style="text-align: center">Razão Social // Nome</div>
                        </f:facet>
                        <h:outputText value="#{empreendimento.idCliente.nomCliente}" />
                    </p:column>

                    <p:column style="text-align: left; " filterBy="#{empreendimento.idCliente.nomFantasia}" sortBy="#{empreendimento.idCliente.nomFantasia}">
                        <f:facet name="header">
                            <div style="text-align: center">Nome Fantasia // Sobrenome</div>
                        </f:facet>
                        <h:outputText value="#{empreendimento.idCliente.nomFantasia}"/>
                    </p:column>

                    <p:column style="text-align: left; " filterBy="#{empreendimento.dscEmpreendimento}" sortBy="#{empreendimento.dscEmpreendimento}">
                        <f:facet name="header">
                            <div style="text-align: center">Empreendimento</div>
                        </f:facet>
                        <h:outputText value="#{empreendimento.dscEmpreendimento}" />
                    </p:column> 

                    <p:column filterStyle="width:100px; text-align: left; " headerText="ASSUNTO" 
                              filterBy="#{empreendimento.dscLote}" sortBy="#{empreendimento.datUpdate}">
                        <h:outputText value="#{empreendimento.datUpdate}">
                            <f:convertDateTime type="date" dateStyle="short" pattern="dd/MM/yyyy HH:mm:ss" />
                        </h:outputText>
                    </p:column>

                    <p:column style="width: 100px;">
                        <f:facet name="header">
                            <div style="text-align: center">ALTERADOS</div>
                        </f:facet>
                        <p:panelGrid style="height: auto;">
                            <p:row>
                                <p:column style="background-color: #{empreendimento.empLoc}; color: #{processoBean.corletraloc};" />
                                <p:column style="background-color: #{empreendimento.empSit}; color: #{processoBean.corletrasit};" />
                                <p:column style="background-color: #{empreendimento.empProc}; color: #{processoBean.corletraproc};" />
                                <p:column style="background-color: #{empreendimento.empAss}; color: #{processoBean.corletraass};" />
                                <p:column style="background-color: #{empreendimento.empCom}; color: #{processoBean.corletracom};" />
                                <p:column style="background-color: #{empreendimento.empDes}; color: #{processoBean.corletrades};" />
                                <p:column style="background-color: #{empreendimento.empErr}; color: #{processoBean.corletraerr};" />
                            </p:row>
                        </p:panelGrid>
                    </p:column>

                    <p:rowExpansion>
                        <p:dataTable id="empreendimentoLoteTable" var="empreendimentoLote" value="#{processoBean.empreendimentoLoteList}" paginator="true" rows="5" 
                                     paginatorPosition="top" filterEvent="enter" rowStyleClass="#{empreendimentoLote.empColor}"
                                     emptyMessage="Nenhum Registro Retornado ..." rowIndexVar="rowIdEmpreendimentoLote">

                            <p:column style="width:250px; text-align: left; " sortBy="#{empreendimentoLote.idAssunto.dscAssunto}">
                                <f:facet name="header">
                                    <div style="text-align: center">Assunto</div>
                                </f:facet>
                                <h:outputText value="#{empreendimentoLote.idAssunto.dscAssunto}" />
                            </p:column>

                            <p:column style="text-align: left; " sortBy="#{empreendimentoLote.dscIdLote}">
                                <f:facet name="header">
                                    <div style="text-align: center">Lote</div>
                                </f:facet>
                                <h:outputText value="#{empreendimentoLote.dscIdLote}" />
                            </p:column>

                            <p:column style="width: 140px; text-align: center;" sortBy="#{empreendimentoLote.numProcesso}">
                                <f:facet name="header">
                                    <div style="text-align: center">Numero Processo</div>
                                </f:facet>
                                <h:outputText value="#{empreendimentoLote.numProcesso}" />
                            </p:column>

                            <p:column style="text-align: left; " sortBy="#{empreendimentoLote.dscOrgao}">
                                <f:facet name="header">
                                    <div style="text-align: center">Orgão</div>
                                </f:facet>
                                <h:outputText value="#{empreendimentoLote.dscOrgao}" />
                            </p:column>

                            <p:column style="width: 130px; text-align: center;" headerText="Data" sortBy="#{empreendimentoLote.datUpdateLote}">
                                <h:outputText value="#{empreendimentoLote.datUpdateLote}">
                                    <f:convertDateTime type="date" dateStyle="short" pattern="dd/MM/yyyy HH:mm:ss"/>
                                </h:outputText>
                            </p:column>

                            <p:column style="text-align: left; " sortBy="#{empreendimentoLote.dscStatus}">
                                <f:facet name="header">
                                    <div style="text-align: center">Status</div>
                                </f:facet>
                                <h:outputText value="#{empreendimentoLote.dscStatus}" />
                            </p:column>

                            <p:column style="text-align: left; " sortBy="#{empreendimentoLote.dscTipoStatus}">
                                <f:facet name="header">
                                    <div style="text-align: center">Tipo Status</div>
                                </f:facet>
                                <h:outputText value="#{empreendimentoLote.dscTipoStatus}" />
                            </p:column>

                            <p:column style="text-align: left; " sortBy="#{empreendimentoLote.dscSinalStatus}">
                                <f:facet name="header">
                                    <div style="text-align: center">Sinal Status</div>
                                </f:facet>
                                <h:outputText value="#{empreendimentoLote.dscSinalStatus}" />
                            </p:column>

                            <p:column style="width: 225px;">
                                <p:commandButton id="selectButton" update=":frmProcesso:panelProcesso :frmProcesso:messages" oncomplete="PF('processoDialog').show();" 
                                                 icon="ui-icon-search" title="Visualizar // Editar">
                                    <f:setPropertyActionListener value="#{empreendimentoLote}" target="#{processoBean.selectedEmprendimentoLote}" />
                                    <f:setPropertyActionListener value="#{rowIdEmpreendimentoLote}" target="#{processoBean.rowIdEmpreendimento}" />
                                </p:commandButton>

                                <p:splitButton value="Sinaliza Status" icon="ui-icon-disk" rendered="#{!processoBean.mostraadmin}">  
                                    <p:menuitem value="Em Andamento" action="#{processoBean.alterarStatusSinal('A')}" update=":frmProcesso:panel :frmProcesso:empreendimentoTable :frmProcesso:messages" icon="ui-icon-arrowrefresh-1-w">
                                        <f:setPropertyActionListener value="#{empreendimentoLote}" target="#{processoBean.selectedEmprendimentoLote}" />
                                    </p:menuitem> 
                                    <p:separator />  
                                    <p:menuitem value="Finalizado" action="#{processoBean.alterarStatusSinal('F')}" update=":frmProcesso:panel :frmProcesso:empreendimentoTable :frmProcesso:messages" icon="ui-icon-close"> 
                                        <f:setPropertyActionListener value="#{empreendimentoLote}" target="#{processoBean.selectedEmprendimentoLote}" />
                                    </p:menuitem>
                                    <p:separator />  
                                    <p:menuitem value="Não Contratado" action="#{processoBean.alterarStatusSinal('N')}" update=":frmProcesso:panel :frmProcesso:empreendimentoTable :frmProcesso:messages" icon="ui-icon-extlink">
                                        <f:setPropertyActionListener value="#{empreendimentoLote}" target="#{processoBean.selectedEmprendimentoLote}" />
                                    </p:menuitem>
                                </p:splitButton>

                                <p:splitButton value="Alterar Status" icon="ui-icon-disk" rendered="#{processoBean.mostraadmin}"> 
                                    <p:separator /> 
                                    <p:menuitem value="Aberto-Triunfo" action="#{processoBean.alterarStatus('T')}" update=":frmProcesso:panel :frmProcesso:empreendimentoTable :frmProcesso:messages" icon="ui-icon-arrowrefresh-1-w">
                                        <f:setPropertyActionListener value="#{empreendimentoLote}" target="#{processoBean.selectedEmprendimentoLote}" />
                                    </p:menuitem>
                                    <p:separator /> 
                                    <p:menuitem value="Aberto-Terceiro" action="#{processoBean.alterarStatus('O')}" update=":frmProcesso:panel :frmProcesso:empreendimentoTable :frmProcesso:messages" icon="ui-icon-arrowrefresh-1-w">
                                        <f:setPropertyActionListener value="#{empreendimentoLote}" target="#{processoBean.selectedEmprendimentoLote}" />
                                    </p:menuitem>
                                    <p:separator />  
                                    <p:menuitem value="Finalizado-Deferido" action="#{processoBean.alterarStatus('D')}" update=":frmProcesso:panel :frmProcesso:empreendimentoTable :frmProcesso:messages" icon="ui-icon-close"> 
                                        <f:setPropertyActionListener value="#{empreendimentoLote}" target="#{processoBean.selectedEmprendimentoLote}" />
                                    </p:menuitem>
                                    <p:separator />  
                                    <p:menuitem value="Finalizado-Indeferido" action="#{processoBean.alterarStatus('I')}" update=":frmProcesso:panel :frmProcesso:empreendimentoTable :frmProcesso:messages" icon="ui-icon-close"> 
                                        <f:setPropertyActionListener value="#{empreendimentoLote}" target="#{processoBean.selectedEmprendimentoLote}" />
                                    </p:menuitem>
                                    <p:separator />
                                    <p:menuitem value="Finalizado-Terceiro" action="#{processoBean.alterarStatus('E')}" update=":frmProcesso:panel :frmProcesso:empreendimentoTable :frmProcesso:messages" icon="ui-icon-close"> 
                                        <f:setPropertyActionListener value="#{empreendimentoLote}" target="#{processoBean.selectedEmprendimentoLote}" />
                                    </p:menuitem>
                                    <p:separator />
                                    <p:menuitem value="Não Contratado" action="#{processoBean.alterarStatus('N')}" update=":frmProcesso:panel :frmProcesso:empreendimentoTable :frmProcesso:messages" icon="ui-icon-extlink">
                                        <f:setPropertyActionListener value="#{empreendimentoLote}" target="#{processoBean.selectedEmprendimentoLote}" />
                                    </p:menuitem>
                                    <p:separator />
                                    <p:menuitem value="Restaurar Arq.Morto" action="#{processoBean.alterarStatus('M')}" update=":frmProcesso:panel :frmProcesso:empreendimentoTable :frmProcesso:messages" icon="ui-icon-extlink">
                                        <f:setPropertyActionListener value="#{empreendimentoLote}" target="#{processoBean.selectedEmprendimentoLote}" />
                                    </p:menuitem>
                                    <p:separator />
                                </p:splitButton>
                            </p:column>
                        </p:dataTable>
                    </p:rowExpansion>
                </p:dataTable>
                <br />
                <div style="text-align: left;">
                    <p:commandButton value="Iniciar Carregamento dos Processos" onclick="PF('confirmation').show();" type="button" icon="ui-icon-disk" rendered="false" />
                    <p:commandButton value="Filtrar Sinalizados" actionListener="#{processoBean.alteraSinal}"  update=":frmProcesso:empreendimentoTable :frmProcesso:messages" icon="ui-icon-battery-1" />
                    <p:commandButton value="Retirar Filtro Sinalizados" actionListener="#{processoBean.tiraSinal}"  update=":frmProcesso:empreendimentoTable :frmProcesso:messages" icon="ui-icon-trash" />
                </div>


                <!-- DETALHE PROCESSO -->
                <p:dialog header="DETALHES DO PROCESSO" widgetVar="processoDialog" resizable="true" id="processoDlg" position="center,top"  minHeight="860" minWidth="1024"
                          showEffect="fade" hideEffect="explode" dynamic="true" maximizable="true">
                    <p:panel id="panelProcesso">
                        <p:dataTable id="processoTable" var="processo" value="#{processoBean.selectedEmprendimentoLote.processoList}" paginator="true" filterEvent="enter" 
                                     rows="5" paginatorPosition="top" emptyMessage="Nenhum Registro Retornado ..."
                                     rowIndexVar="rowIdProcesso" rowStyleClass="#{processo.empColor}">

                            <p:column style="width:150px; text-align: left;" sortBy="#{processo.idEmpreendimentoLote.numProcesso}">
                                <f:facet name="header">
                                    <div style="text-align: center">No.Processo</div>
                                </f:facet>
                                <h:outputText value="#{processo.idEmpreendimentoLote.numProcesso}" />
                            </p:column>

                            <p:column style="width:200px; text-align: left; " sortBy="#{processo.procMotivo}">
                                <f:facet name="header">
                                    <div style="text-align: center">Assunto</div>
                                </f:facet>
                                <h:outputText value="#{processo.procMotivo}" />
                            </p:column>

                            <p:column style="width:200px; text-align: center;" headerText="Data" sortBy="#{processo.datUpdate}">
                                <h:outputText value="#{processo.datUpdate}">
                                    <f:convertDateTime type="date" dateStyle="short" pattern="dd/MM/yyyy HH:mm:ss"/>
                                </h:outputText>
                            </p:column>

                            <p:column style="width: 80px;">
                                <h:panelGrid columns="5" styleClass="actions" cellpadding="0">
                                    <p:commandButton id="selectButtonProcesso" update=":frmProcesso:panelProcesso :frmProcesso:messages" 
                                                     icon="ui-icon-search" title="Visualizar">
                                        <f:setPropertyActionListener value="#{processo}" target="#{processoBean.selectedProcesso}" />
                                        <f:setPropertyActionListener value="#{false}" target="#{processoBean.updateAssunto}" />
                                        <f:setPropertyActionListener value="#{false}" target="#{processoBean.incluirAssunto}" />
                                        <f:setPropertyActionListener value="#{rowIdProcesso}" target="#{processoBean.rowidprocesso}" />
                                    </p:commandButton>

                                    <p:commandButton id="alterarButtonProcesso" update=":frmProcesso:panelProcesso :frmProcesso:messages" 
                                                     icon="ui-icon-document" title="Alterar Processo">
                                        <f:setPropertyActionListener value="#{processo}" target="#{processoBean.selectedProcesso}" />
                                        <f:setPropertyActionListener value="#{false}" target="#{processoBean.updateAssunto}" />
                                        <f:setPropertyActionListener value="#{false}" target="#{processoBean.incluirAssunto}" />
                                        <f:setPropertyActionListener value="#{rowIdProcesso}" target="#{processoBean.rowidprocesso}" />
                                    </p:commandButton>

                                    <p:commandButton id="excluirButtonProcesso" update=":frmProcesso:panelProcesso :frmProcesso:processoTable :frmProcesso:messages" 
                                                     icon="ui-icon-trash" title="Excluir Linha do Processo" oncomplete="PF('confirmationProcesso').show()">
                                        <f:setPropertyActionListener value="#{processo}" target="#{processoBean.selectedProcesso}" />
                                        <f:setPropertyActionListener value="#{false}" target="#{processoBean.updateAssunto}" />
                                        <f:setPropertyActionListener value="#{false}" target="#{processoBean.incluirAssunto}" />
                                        <f:setPropertyActionListener value="#{rowIdProcesso}" target="#{processoBean.rowidprocesso}" />
                                    </p:commandButton>

                                    <p:commandButton id="enviarEmail" update=":frmProcesso:panelEmail :frmProcesso:messages" 
                                                     icon="ui-icon-mail-open" title="Enviar E-Mail" oncomplete="PF('composeDlg').show()">
                                        <f:setPropertyActionListener value="#{processo}" target="#{processoBean.selectedProcesso}" />
                                    </p:commandButton>
                                </h:panelGrid>
                            </p:column>

                            <f:facet name="footer">
                                <div style="text-align: left;">
                                    <p:commandButton id="incluirButtonProcesso" actionListener="#{processoBean.preparaInserir}" 
                                                     update=":frmProcesso:panelProcesso :frmProcesso:messages" value="Novo Processo"
                                                     icon="ui-icon-pencil" title="Cadastrar Novo Processo" />
                                </div>
                            </f:facet>
                        </p:dataTable>

                        <p:accordionPanel id="accordion"  widgetVar="accordion" activeIndex="#{processoBean.ativaAccordion}" style="width: 100%;" >
                            <p:tab title="COMUNIQUE-SE" rendered="#{not empty processoBean.selectedProcesso.comTexto}" titleStyle="text-align: center; font-weight: bold;">
                                <p:panelGrid id="displayComunique" style="width: 100%;">
                                    <p:row>
                                        <p:column style="font-weight: bold; text-align: left">Numero:</p:column>
                                        <p:column style="text-align: left; width:100px;">
                                            <p:inputText id="inNumero" value="#{processoBean.selectedProcesso.comNumero}" style="width:100px; font-weight:bold;" />
                                        </p:column>

                                        <p:column style="font-weight: bold; text-align: left">Numero Triunfo:</p:column>
                                        <p:column style="text-align: left; width:100px;">
                                            <p:inputText id="inNumeroTriunfo" value="#{processoBean.selectedProcesso.numTriunfo}" style="width:100px; font-weight:bold;" />
                                        </p:column>

                                        <p:column style="font-weight: bold; text-align: left">Data:</p:column>
                                        <p:column style="text-align: left; width:100px;">
                                            <p:inputMask id="inDatCom" value="#{processoBean.selectedProcesso.comData}" mask="99/99/9999" style="font-weight:bold; width:100px;">
                                                <f:convertDateTime type="date" dateStyle="short" pattern="dd/MM/yyyy"/>
                                            </p:inputMask>
                                        </p:column>

                                        <p:column style="font-weight: bold; text-align: left">Atendido:</p:column>
                                        <p:column style="text-align: left; width:100px;" colspan="7">
                                            <p:inputMask id="inDatAtendido" value="#{processoBean.selectedProcesso.datAtendido}" mask="99/99/9999" style="font-weight:bold; width:100px;">
                                                <f:convertDateTime type="date" dateStyle="short" pattern="dd/MM/yyyy"/>
                                            </p:inputMask>
                                        </p:column>
                                    </p:row>

                                    <p:row>
                                        <p:column style="font-weight: bold; text-align: left">1-Prorrogação:</p:column>
                                        <p:column style="text-align: left; width:100px;">
                                            <p:inputMask id="inDatProc1" value="#{processoBean.selectedProcesso.datProrrogacao1}" mask="99/99/9999" style="font-weight:bold; width:100px;">
                                                <f:convertDateTime type="date" dateStyle="short" pattern="dd/MM/yyyy"/>
                                            </p:inputMask>
                                        </p:column> 

                                        <p:column style="font-weight: bold; text-align: left">1-Concessão:</p:column>
                                        <p:column style="text-align: left; width:100px;">
                                            <p:inputMask id="inDatCon1" value="#{processoBean.selectedProcesso.datConcessao1}" mask="99/99/9999" style="font-weight:bold; width:100px;">
                                                <f:convertDateTime type="date" dateStyle="short" pattern="dd/MM/yyyy"/>
                                            </p:inputMask>
                                        </p:column>

                                        <p:column style="font-weight: bold; text-align: left">2-.Prorrogação:</p:column>
                                        <p:column style="text-align: left; width:100px;">
                                            <p:inputMask id="inDatProc2" value="#{processoBean.selectedProcesso.datProrrogacao2}" mask="99/99/9999" style="font-weight:bold; width:100px;">
                                                <f:convertDateTime type="date" dateStyle="short" pattern="dd/MM/yyyy"/>
                                            </p:inputMask>
                                        </p:column> 

                                        <p:column style="font-weight: bold; text-align: left">2-Concessão:</p:column>
                                        <p:column style="text-align: left; width:100px;">
                                            <p:inputMask id="inDatCon2" value="#{processoBean.selectedProcesso.datConcessao2}" mask="99/99/9999" style="font-weight:bold; width:100px;">
                                                <f:convertDateTime type="date" dateStyle="short" pattern="dd/MM/yyyy"/>
                                            </p:inputMask>
                                        </p:column>

                                        <p:column style="font-weight: bold; text-align: left">3-Prorrogação:</p:column>
                                        <p:column style="text-align: left; width:100px;">
                                            <p:inputMask id="inDatProc3" value="#{processoBean.selectedProcesso.datProrrogacao3}" mask="99/99/9999" style="font-weight:bold; width:100px;">
                                                <f:convertDateTime type="date" dateStyle="short" pattern="dd/MM/yyyy"/>
                                            </p:inputMask>
                                        </p:column> 

                                        <p:column style="font-weight: bold; text-align: left">3-Concessão:</p:column>
                                        <p:column style="text-align: left; width:100px;" colspan="3">
                                            <p:inputMask id="inDatCon3" value="#{processoBean.selectedProcesso.datConcessao3}" mask="99/99/9999" style="font-weight:bold; width:100px;">
                                                <f:convertDateTime type="date" dateStyle="short" pattern="dd/MM/yyyy"/>
                                            </p:inputMask>
                                        </p:column>
                                    </p:row>

                                    <p:row>
                                        <p:column style="font-weight: bold; text-align: left">Descritivo:</p:column>
                                        <p:column style="text-align: left;" colspan="13">
                                            <p:inputTextarea id="inTexto" readonly="true" autoResize="false" value="#{processoBean.selectedProcesso.comTexto}" style="font-weight:bold; width: 1000px; height: 200px;" />
                                        </p:column>
                                    </p:row>
                                </p:panelGrid>

                            </p:tab> 
                            <p:tab title="LOCALIZAÇÃO" titleStyle="text-align: center; font-weight: bold;">
                                <p:panelGrid id="displayLocalizacao" styleClass="ui-widget-content grid" style="width: 100%;">
                                    <p:row>
                                        <p:column style="font-weight: bold; text-align: left">Unidade:</p:column>
                                        <p:column style="text-align: left; ">
                                            <p:inputText id="inUnidade" value="#{processoBean.selectedProcesso.locUnidade}" style="width:400px; font-weight:bold;" />
                                        </p:column>
                                        <p:column style="font-weight: bold; text-align: left">Desde:</p:column>
                                        <p:column style="text-align: left">
                                            <p:inputMask id="inDatCotacao" value="#{processoBean.selectedProcesso.locDatDesde}" mask="99/99/9999" style="font-weight:bold; ">
                                                <f:convertDateTime type="date" dateStyle="short" pattern="dd/MM/yyyy"/>
                                            </p:inputMask>
                                        </p:column>
                                    </p:row>

                                    <p:row>
                                        <p:column style="font-weight: bold; text-align: left">Descrição:</p:column>
                                        <p:column colspan="3" style="text-align: left; ">
                                            <p:inputText id="inDescricao" value="#{processoBean.selectedProcesso.locDescricao}" style="width:700px; font-weight:bold;" />
                                        </p:column>
                                    </p:row>

                                    <p:row>
                                        <p:column style="font-weight: bold; text-align: left">Transito:</p:column>
                                        <p:column colspan="3" style="text-align: left; ">
                                            <p:inputText id="inTransito" value="#{processoBean.selectedProcesso.locTransito}" style="width:700px; font-weight:bold;" />
                                        </p:column>
                                    </p:row>

                                    <p:row>
                                        <p:column style="font-weight: bold; text-align: left">Endereço:</p:column>
                                        <p:column style="text-align: left; ">
                                            <p:inputText id="inEndereco" value="#{processoBean.selectedProcesso.locEndereco}" style="width:700px; font-weight:bold;" />
                                        </p:column>
                                        <p:column style="font-weight: bold; text-align: left">Bairro:</p:column>
                                        <p:column style="text-align: left; ">
                                            <p:inputText id="inBairro" value="#{processoBean.selectedProcesso.locBairro}" style="width:300px; font-weight:bold;" />
                                        </p:column>
                                    </p:row>

                                    <p:row>
                                        <p:column style="font-weight: bold; text-align: left">Em poder do funcionário:</p:column>
                                        <p:column style="text-align: left; ">
                                            <p:inputText id="inFuncionario" value="#{processoBean.selectedProcesso.locFunciionario}" style="width:700px; font-weight:bold;" />
                                        </p:column>
                                        <p:column style="font-weight: bold; text-align: left">R.F:</p:column>
                                        <p:column style="text-align: left; ">
                                            <p:inputText id="inRf" value="#{processoBean.selectedProcesso.locRf}" style="width:200px; font-weight:bold;" />
                                        </p:column>
                                    </p:row>

                                    <p:row>
                                        <p:column style="font-weight: bold; text-align: left">Telefone:</p:column>
                                        <p:column style="text-align: left; ">
                                            <p:inputText id="inTelefone" value="#{processoBean.selectedProcesso.locTelefone}" style="width:200px; font-weight:bold;" />
                                        </p:column>
                                        <p:column style="font-weight: bold; text-align: left">Ramal:</p:column>
                                        <p:column style="text-align: left">
                                            <p:inputText id="inRamal" value="#{processoBean.selectedProcesso.locRamal}" style="width:100px; font-weight:bold;" />
                                        </p:column>
                                    </p:row>

                                    <p:row>
                                        <p:column style="font-weight: bold; text-align: left">E-Mail:</p:column>
                                        <p:column colspan="3" style="text-align: left">
                                            <p:inputText id="inEmail" value="#{processoBean.selectedProcesso.locEmail}" style="width:700px; font-weight:bold;" />
                                        </p:column>
                                    </p:row>
                                </p:panelGrid>
                            </p:tab>
                            <p:tab title="SITUAÇÃO" titleStyle="text-align: center; font-weight: bold;">
                                <p:panelGrid id="displaySituacao" styleClass="ui-widget-content grid">
                                    <p:row>
                                        <p:column style="font-weight: bold; text-align: left">Data:</p:column>
                                        <p:column style="text-align: left">
                                            <p:inputMask id="inDataSituacao" value="#{processoBean.selectedProcesso.sitDataSituacao}" mask="99/99/9999" style="font-weight:bold; ">
                                                <f:convertDateTime type="date" dateStyle="short" pattern="dd/MM/yyyy"/>
                                            </p:inputMask>
                                        </p:column>
                                        <p:column style="font-weight: bold; text-align: left">Descrição:</p:column>
                                        <p:column colspan="3" style="text-align: left; ">
                                            <p:inputText id="inSitDescricao" value="#{processoBean.selectedProcesso.sitDescricao}" style="width:400px; font-weight:bold;" />
                                        </p:column>
                                    </p:row>

                                    <p:row>
                                        <p:column style="font-weight: bold; text-align: left;">Despacho:</p:column>
                                        <p:column style="text-align: left; ">
                                            <p:inputText id="inDespacho" value="#{processoBean.selectedProcesso.sitDespacho}" style="width:400px; font-weight:bold;" />
                                        </p:column>
                                        <p:column style="font-weight: bold; text-align: left">Data:</p:column>
                                        <p:column style="text-align: left">
                                            <p:inputMask id="inDataDescricao" value="#{processoBean.selectedProcesso.sitSituacaoDataDescricao}" mask="99/99/9999" style="font-weight:bold; ">
                                                <f:convertDateTime type="date" dateStyle="short" pattern="dd/MM/yyyy"/>
                                            </p:inputMask>
                                        </p:column>

                                        <p:column style="font-weight: bold; text-align: left">D.O.M.:</p:column>
                                        <p:column style="text-align: left; ">
                                            <p:inputText id="inDom" value="#{processoBean.selectedProcesso.sitDom}" style="width:200px; font-weight:bold;" />
                                        </p:column>
                                    </p:row>

                                    <p:row>
                                        <p:column style="font-weight: bold; text-align: left">Comunique-se:</p:column>
                                        <p:column style="text-align: left; ">
                                            <p:inputText id="inComunique" value="#{processoBean.selectedProcesso.sitComunique}" style="width:700px; font-weight:bold;" />
                                        </p:column>
                                        <p:column style="font-weight: bold; text-align: left">Vencimento:</p:column>
                                        <p:column colspan="3" style="text-align: left">
                                            <p:inputMask id="inVencimento" value="#{processoBean.selectedProcesso.sitVencimento}" mask="99/99/9999" style="font-weight:bold; ">
                                                <f:convertDateTime type="date" dateStyle="short" pattern="dd/MM/yyyy"/>
                                            </p:inputMask>
                                        </p:column>
                                    </p:row>
                                </p:panelGrid>
                            </p:tab>
                            <p:tab title="DADOS DO PROCESSO" titleStyle="text-align: center; font-weight: bold;">
                                <p:panelGrid id="displayProcesso" styleClass="ui-widget-content grid" style="width: 100%;">
                                    <p:row>
                                        <p:column style="font-weight: bold; text-align: left">Assunto:</p:column>
                                        <p:column style="text-align: left; ">
                                            <p:inputText id="inProcAssunto" value="#{processoBean.selectedProcesso.procAssunto}" style="width:700px; font-weight:bold;" />
                                        </p:column>
                                    </p:row>

                                    <p:row>
                                        <p:column style="font-weight: bold; text-align: left">Motivo da Autuação:</p:column>
                                        <p:column style="text-align: left; ">
                                            <p:inputText id="inProcMotivo" value="#{processoBean.selectedProcesso.procMotivo}" style="width:700px; font-weight:bold;" />
                                        </p:column>
                                    </p:row>

                                    <p:row>
                                        <p:column style="font-weight: bold; text-align: left">Interessado:</p:column>
                                        <p:column style="text-align: left">
                                            <p:inputText id="inProcInteressado" value="#{processoBean.selectedProcesso.procInteressado}" style="width:700px; font-weight:bold;" />
                                        </p:column>
                                    </p:row>
                                </p:panelGrid>
                            </p:tab>
                            <p:tab title="ASSUNTOS SOLICITADOS" titleStyle="text-align: center; font-weight: bold;">
                                <p:dataTable id="assuntoTable" var="assunto" value="#{processoBean.selectedProcesso.processoSituacaoList}" paginator="true" filterEvent="enter" 
                                             rows="5" paginatorPosition="top" emptyMessage="Nenhum Registro Retornado ..." rowIndexVar="rowIdProcessoSituacao">

                                    <p:column style="width: 200px; text-align: center;" headerText="DATA" sortBy="#{assunto.assData}">
                                        <h:outputText value="#{assunto.assData}">
                                            <f:convertDateTime type="date" dateStyle="short" pattern="dd/MM/yyyy HH:mm:ss"/>
                                        </h:outputText>
                                    </p:column>

                                    <p:column style="width:500px; text-align: left;">
                                        <f:facet name="header">
                                            <div style="text-align: center;">ASSUNTO</div>
                                        </f:facet>
                                        <h:outputText value="#{assunto.assDescricao}" />
                                    </p:column>

                                    <p:column style="width:500px; text-align: left;">
                                        <f:facet name="header">
                                            <div style="text-align: center;">SITUAÇÃO</div>
                                        </f:facet>
                                        <h:outputText value="#{assunto.assSituacao}" />
                                    </p:column>

                                    <p:column style="width: 50px">
                                        <h:panelGrid columns="4" styleClass="actions" cellpadding="0">
                                            <p:commandButton id="selectButtonProcessoAssunto" update=":frmProcesso:panelProcesso :frmProcesso:messages" 
                                                             icon="ui-icon-search" title="Visualizar Assunto">
                                                <f:setPropertyActionListener value="#{assunto}" target="#{processoBean.selectedProcessoSituacao}" />
                                                <f:setPropertyActionListener value="#{false}" target="#{processoBean.updateAssunto}" />
                                                <f:setPropertyActionListener value="#{false}" target="#{processoBean.incluirAssunto}" />
                                            </p:commandButton>

                                            <p:commandButton id="alterarButtonProcessoAssunto" update=":frmProcesso:panelProcesso :frmProcesso:messages" 
                                                             icon="ui-icon-document" title="Alterar Assunto">
                                                <f:setPropertyActionListener value="#{assunto}" target="#{processoBean.selectedProcessoSituacao}" />
                                                <f:setPropertyActionListener value="#{rowIdProcessoSituacao}" target="#{processoBean.rowId}" />
                                                <f:setPropertyActionListener value="#{true}" target="#{processoBean.updateAssunto}" />
                                                <f:setPropertyActionListener value="#{false}" target="#{processoBean.incluirAssunto}" />
                                            </p:commandButton>

                                            <p:commandButton id="excluirButtonProcessoAssunto" update=":frmProcesso:panelProcesso :frmProcesso:messages" 
                                                             icon="ui-icon-trash" title="Excluir Linha do Assunto" oncomplete="PF('confirmationProcessoAssunto').show()">
                                                <f:setPropertyActionListener value="#{assunto}" target="#{processoBean.selectedProcessoSituacao}" />
                                                <f:setPropertyActionListener value="#{false}" target="#{processoBean.updateAssunto}" />
                                                <f:setPropertyActionListener value="#{false}" target="#{processoBean.incluirAssunto}" />
                                            </p:commandButton>
                                        </h:panelGrid>
                                    </p:column>

                                    <f:facet name="footer">
                                        <div style="text-align: left;">
                                            <p:commandButton id="incluirButtonProcessoAssunto" actionListener="#{processoBean.preparaInserirAssunto}" 
                                                             update=":frmProcesso:panelProcesso :frmProcesso:messages" value="Novo Assunto"
                                                             icon="ui-icon-pencil" title="Cadastrar Novo Assunto" />
                                        </div>
                                    </f:facet>
                                </p:dataTable>

                                <p:panelGrid id="displayProcessoSituacao" columns="4" style="width: 100%">
                                    <f:facet name="header">
                                        <p:row>
                                            <p:column style="font-weight: bold;" colspan="4">Detalhes Assuntos Solicitados</p:column>
                                        </p:row>
                                    </f:facet>

                                    <p:row>
                                        <p:column style="font-weight: bold;">Data: </p:column>
                                        <p:column>
                                            <p:inputMask id="inAssData" value="#{processoBean.selectedProcessoSituacao.assData}" mask="99/99/9999" style="font-weight:bold; ">
                                                <f:convertDateTime type="date" dateStyle="short" pattern="dd/MM/yyyy"/>
                                            </p:inputMask>
                                        </p:column>

                                        <p:column style="font-weight: bold;">Assunto: </p:column>
                                        <p:column>
                                            <p:inputText style="width:60%; font-weight:bold;" id="inAssDescricao" value="#{processoBean.selectedProcessoSituacao.assDescricao}" />
                                        </p:column>
                                    </p:row>

                                    <p:row>
                                        <p:column style="font-weight: bold;">Situação: </p:column>
                                        <p:column colspan="3">
                                            <p:inputText style="width:30%; font-weight:bold;" id="inAssSituacao" value="#{processoBean.selectedProcessoSituacao.assSituacao}" />
                                        </p:column> 
                                    </p:row>
                                </p:panelGrid>

                                <div id="divButtonAssunto" style="text-align: left;">
                                    <p:commandButton id="btInserirAssunto" value="Inserir Assunto" actionListener="#{processoBean.inserirAssunto}" rendered="#{processoBean.incluirAssunto}" 
                                                     update=":frmProcesso:accordion :frmProcesso:messages" icon="ui-icon-pencil" title="Inserir Novo Assunto Solicitado" />

                                    <p:commandButton id="btAlterarAssunto" value="Alterar Assunto" actionListener="#{processoBean.alterarAssunto}" rendered="#{processoBean.updateAssunto}"
                                                     update=":frmProcesso:accordion :frmProcesso:messages" icon="ui-icon-document" title="Alterar Assunto Solicitado" />
                                </div>
                            </p:tab>

                            <p:tab title="DESPACHO" titleStyle="text-align: center; font-weight: bold;">
                                <p:panelGrid id="displayDespacho" style="width: 100%;">
                                    <p:row>
                                        <p:column style="font-weight: bold; text-align: left">Descrição:</p:column>
                                        <p:column style="text-align: left; width:500px;">
                                            <p:inputText id="inDesDescricao" value="#{processoBean.selectedProcesso.desDescricao}" style="width:500px; font-weight:bold;" />
                                        </p:column>

                                        <p:column style="font-weight: bold; text-align: left">Despacho:</p:column>
                                        <p:column style="text-align: left; width:200px;">
                                            <p:inputText id="inDesDespacho" value="#{processoBean.selectedProcesso.desDespacho}" style="font-weight:bold; width:300px;" />
                                        </p:column>


                                    </p:row>
                                    <p:row>
                                        <p:column style="font-weight: bold; text-align: left">Data:</p:column>
                                        <p:column style="text-align: left; width:100px;">
                                            <p:inputMask id="inDatDes" value="#{processoBean.selectedProcesso.desData}" mask="99/99/9999" style="font-weight:bold; width:100px;">
                                                <f:convertDateTime type="date" dateStyle="short" pattern="dd/MM/yyyy"/>
                                            </p:inputMask>
                                        </p:column>

                                        <p:column style="font-weight: bold; text-align: left">Motivo:</p:column>
                                        <p:column style="text-align: left; width:500px;">
                                            <p:inputText id="inDesMotivo" value="#{processoBean.selectedProcesso.desMotivo}" style="font-weight:bold; width:500px;" />
                                        </p:column> 
                                    </p:row>
                                </p:panelGrid>
                            </p:tab>

                            <p:tab title="AÇÕES" titleStyle="text-align: center; font-weight: bold;">
                                <p:inputTextarea id="editorObs" widgetVar="editorObs" autoResize="false" value="#{processoBean.selectedProcesso.idEmpreendimentoLote.dscObs}" style="width: 1000px; height: 200px;"/>
                            </p:tab>

                        </p:accordionPanel>
                        <br />
                        <div id="divButton" style="text-align: left;">
                            <p:commandButton id="btInserir" value="Inserir Processo" actionListener="#{processoBean.inserir}" update=":frmProcesso:panel :frmProcesso:messages" 
                                             icon="ui-icon-pencil" title="Gravar Novo Projeto" rendered="#{processoBean.incluir}"  oncomplete="PF('processoDialog').hide()" />

                            <p:commandButton id="btAlterar" value="Alterar Processo" actionListener="#{processoBean.alterar}" update=":frmProcesso:panel :frmProcesso:messages" 
                                             icon="ui-icon-document" title="Alterar Processo" rendered="#{processoBean.update}"  oncomplete="PF('processoDialog').hide()" />
                            
                            <p:commandButton id="btFechar" value="Fechar" update=":frmProcesso:panel :frmProcesso:messages" 
                                             icon="ui-icon-document" title="Fechar Tela dos Históricos!" onclick="PF('processoDialog').hide();" />
                        </div>
                    </p:panel>

                </p:dialog>
                
                <!-- CONFIRMA CARREGAMENTO DOS PROCESSOS -->
                <p:dialog header="Confirma o Carregamento dos Processos?" widgetVar="confirmation">  

                    <p:commandButton value="Sim" update=":frmProcesso:panel, :frmProcesso:empreendimentoTable, :frmProcesso:messages" onstart="PF('statusDialog').show();" 
                                     onclick="PF('confirmation').hide();"
                                     actionListener="#{processoBean.calculaProcesso}" process="@all" />  
                    <p:commandButton value="Não" onclick="PF('confirmation').hide();" type="button" />   

                </p:dialog>
                <!-- CONFIRMA EXCLUIR PROCESSO -->
                <p:dialog header="Confirma a Exclusão dessa Linha do Processo: #{processoBean.selectedProcesso.procAssunto}?" widgetVar="confirmationProcesso">  

                    <p:commandButton value="Sim" update=":frmProcesso:panel :frmProcesso:messages" oncomplete="PF('confirmationProcesso').hide();"
                                     actionListener="#{processoBean.excluir}" />  
                    <p:commandButton value="Não" onclick="PF('confirmationProcesso').hide();" type="button" />   

                </p:dialog>
                <!-- CONFIRMA EXCLUIR ASSUNTO -->
                <p:dialog header="Confirma a Exclusão dessa Linha do Assunto: #{processoBean.selectedProcessoSituacao.assDescricao}?" widgetVar="confirmationProcessoAssunto">  

                    <p:commandButton value="Sim" update=":frmProcesso:panelProcesso, :frmProcesso:messages" oncomplete="PF('confirmationProcessoAssunto').hide()"
                                     actionListener="#{processoBean.excluirAssunto}" />  
                    <p:commandButton value="Não" onclick="PF('confirmationProcessoAssunto').hide();" type="button" />   

                </p:dialog>
                <!-- TELA ESPERA CARREGAMENTO -->
                <p:dialog id="DialogStatus" widgetVar="statusDialog" header="Aguarde ... Carregadando os Processos ..." draggable="false" closable="false" 
                          onShow="pbAjax.start();" modal="true">
                    <p:graphicImage value="/design/ajaxloadingbar.gif" />
                    <br />
                    <h:outputText value="EMPREENDIMENTOS" style="text-align: left; font-weight:bold;" />

                    <p:progressBar id="ajaxPB" widgetVar="pbAjax" ajax="true" value="#{processoBean.progress}" labelTemplate="{value}%" styleClass="animated">
                        <p:ajax event="complete" listener="#{processoBean.onComplete}" update="messages" />
                    </p:progressBar>
                </p:dialog>
                <!-- ENVIAR E-MAIL -->
                <p:dialog widgetVar="composeDlg" header="Novo E-Mail" width="1200" showEffect="fade" hideEffect="fade" position="top">
                    <p:panel id="panelEmail">
                        <p:tooltip id="toolTipSlide" for="to" value="Clique no botão para Incluir um novo E-Mail"
                                   showEffect="slide" hideEffect="slide" />
                        <p:panelGrid style="text-align: left;">
                            <p:row>
                                <p:column>
                                    <p:commandButton value="Para:" onclick="PF('emailDlg').show();" style="text-align: left; font-weight:bold;"
                                                     icon="ui-icon-mail-open" />
                                </p:column>
                                <p:column>
                                    <p:inputText id="to" value="#{processoBean.email}" style="width: 700px;" readonly="true" />
                                </p:column>
                            </p:row>

                            <p:row>
                                <p:column>
                                    <h:outputLabel for="subject" value="Assunto: " style="text-align: left; font-weight:bold;" />
                                </p:column>
                                <p:column>
                                    <p:inputText id="subject" value="#{processoBean.assunto}" style="width: 700px;" />
                                </p:column>
                            </p:row>
                        </p:panelGrid>

                        <p:separator />

                        <p:editor id="editor" widgetVar="editor" value="#{processoBean.texto}" width="1100" height="500"/>

                        <p:separator />
                        <div style="text-align: left;">
                            <p:commandButton value="Enviar" oncomplete="PF('composeDlg').hide()" actionListener="#{processoBean.enviarEmail}" 
                                             icon="ui-icon-mail-open" update=":frmProcesso:panel, :frmProcesso:messages" process="@all" />
                            <p:commandButton value="Cancelar" onclick="PF('composeDlg').hide()" type="button" icon="ui-icon-close" />
                        </div>
                    </p:panel>
                </p:dialog>
                <!-- ESCOLHA E-MAIL -->
                <p:dialog widgetVar="emailDlg" header="Pesquisa de E-Mail" width="1000" showEffect="fade" hideEffect="fade" position="right,top">
                    <p:dataTable id="emailTable" var="email" value="#{processoBean.viewEmailLazyModel}" filterEvent="enter" 
                                 paginator="true" rows="5" paginatorPosition="top" lazy="true" emptyMessage="Nenhum Registro Retornado ...">

                        <p:column style="width:1000px; text-align: left;" filterBy="#{email.name}" sortBy="#{email.name}">
                            <f:facet name="header">
                                <div style="text-align: center">Nome // Razão Social</div>
                            </f:facet>
                            <h:outputText value="#{email.name}"/>
                        </p:column>

                        <p:column style="width:1000px; text-align: left;" filterBy="#{email.complemento}" sortBy="#{email.complemento}">
                            <f:facet name="header">
                                <div style="text-align: center">Complemento // Nome Fantasia</div>
                            </f:facet>
                            <h:outputText value="#{email.complemento}"/>
                        </p:column>

                        <p:column style="width:1000px; text-align: left;" filterBy="#{email.email}" sortBy="#{email.email}">
                            <f:facet name="header">
                                <div style="text-align: center">E-Mail</div>
                            </f:facet>
                            <h:outputText value="#{email.email}"/>
                        </p:column>

                        <p:column style="width: 50px">
                            <p:panelGrid styleClass="actions" columns="1">
                                <p:commandButton id="selectButtonEMail" update=":frmProcesso:panelEmail :frmProcesso:messages" 
                                                 icon="ui-icon-check" title="Selecionar E-Mail" oncomplete="PF('emailDlg').hide()">
                                    <f:setPropertyActionListener value="#{email}" target="#{processoBean.selectedViewEmail}" />
                                </p:commandButton>
                            </p:panelGrid>
                        </p:column>
                    </p:dataTable>
                </p:dialog>
            </p:panel>
        </h:form>
    </ui:define>
</ui:composition> 